package com.xcc.config;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.io.*;

/**
 * @author frosty
 * @description
 * @date 2019-12-06 06:13:02
 */


public class ReadJson {
    /**
     * 读取json文件，返回json串
     * @param fileName
     * @return
     */
    public static String readJsonFile(String fileName) {
        String jsonStr = "";
        try {
            File jsonFile = new File(fileName);
            FileReader fileReader = new FileReader(jsonFile);

            Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8");
            int ch = 0;
            StringBuffer sb = new StringBuffer();
            while ((ch = reader.read()) != -1) {
                sb.append((char) ch);
            }
            fileReader.close();
            reader.close();
            jsonStr = sb.toString();
            return jsonStr;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }


    public static void main(String[] args) throws  Exception{

           int a=10;
           int b;
//           if(b=a){
               System.out.println(b=a);
//           }


//        String path = "/home/swst/data.json";
//        String s = readJsonFile(path);
//        JSONObject jobj = JSON.parseObject(s);
//        System.out.println(jobj);
//                JSONArray features = jobj.getJSONArray("features");
//                JSONObject geometry0=features.getJSONObject(0).getJSONObject("geometry");
//               JSONArray    coordinates= geometry0.getJSONArray("coordinates");
//           Double [][] stri=new Double[coordinates.size()][];
//           stri[0]= new Double[]{37558950.12588133, 3439186.8208991587};
//         // stri[1]= new String[]{"1234", "2324"};
//
//               coordinates.set(0,stri);
//               geometry0.put("coordinates",coordinates);
//                JSONObject js=features.getJSONObject(0);
//                js.put("geometry",geometry0);
//                features.set(0,js);
//             jobj.put("features",features);
//            System.out.println(jobj);
          //OutputStreamWriter opt=new OutputStreamWriter(new FileOutputStream("/home/swst/data2.json"),"utf-8");
          //opt.write(jsonArray.toString());
          //opt.flush();
          //opt.close();
    }

}
